<template>
  <section :class="[!isSetPageBackground ? 'c-bg-white' : '']">
    <cust-title-com v-if="item.isShowTitle"
      :marginSettings="item.styleParam && item.styleParam.marginSettings ? item.styleParam.marginSettings : null"
      :headLine="item.styleParam && item.styleParam.headLine ? item.styleParam.headLine : null"
      :showMoreType="item.showMoreType" :titleName="item.title || '领券中心'"
      :titleDesc="item.desc || '先领券 再购买'"
      :showMore="item.isShowMore == 1" @clickMore="goValueVoucherList(index)" class="c-ph24"></cust-title-com>
    <coupon-item class="c-pt24"
      :marginSettings="item.styleParam && item.styleParam.marginSettings ? item.styleParam.marginSettings : null"
      :headLine="item.styleParam && item.styleParam.headLine ? item.styleParam.headLine : null"
      :isMicroPage="pageName != 'INDEX'" :items="item.items.prods" :orderBy="item.items.orderBy"
      :pageName="pageName"
    ></coupon-item>
  </section>
</template>
<script>
import { appRouterChange } from "@/mixin/appRouterPush.js";
import custTitleCom from "@/components/templates/custIndexTemp/custTitleCom.vue";
import couponItem from "@/components/templates/couponItem.vue";
export default {
  name: "CampIndexCom",
  mixins: [appRouterChange],
  components: {
    custTitleCom,
    couponItem
  },
  props: {
    item: {
      type: Object,
      default: () => {
        return {}
      },
    },
    pageName: {//首页INDEX 预览页PREVIEW_INDEX 微页面MICRO_PAGE
      type: String,
      default: "INDEX"
    },
    index: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      mId: '', //微页面id
      isSetPageBackground: sessionStorage.getItem("isSetPageBackground") || 0
    };
  },
  methods: {
    goValueVoucherList(index) {
      if (this.pageName == 'PREVIEW_INDEX') {
        return;
      }
      let toPath = `/homePage/valueVoucher/list?modulesKey=${this.index}&mId=${this.mId}`;
      if (this.item && this.item.items && this.item.items.productType && [1, 2].includes(this.item.items.productType)) {
        toPath = `${toPath}&productType=${this.item.items.productType}${this.item.items.productType == 1 ? '&isMall=1' : ''}`
      }
      this.iosAppRouteChange(toPath);
    },
  },
  activated() {
    this.mId = this.$route.query.mId || '';
  },
};
</script>

<style scoped>
</style>
